﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PresentationLayerMVC.Models.BookingViewModels>" %>


<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	CheckBooking
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script src="<%= Url.Content("~/Scripts/MicrosoftAjax.js") %>" type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.js") %>" type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/MicrosoftMvcValidation.js") %>" type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/jquery-1.9.0.min.js") %>" type="text/javascript"></script>
    <h2>Booking Details     </h2>
<%if (Model.booking != null)
  {
 %>   
<table style="width: 100%">
	<tr>
		<td bgcolor="#C0C0C0" colspan="4" style="height: 23px">Booking Details</td>
	</tr>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#booking_Guest_Phone").keydown(function (event) {
                // Allow: backspace, delete, tab, escape, and enter
                if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
                // Allow: Ctrl+A
            (event.keyCode == 65 && event.ctrlKey === true) ||
                // Allow: home, end, left, right
            (event.keyCode >= 35 && event.keyCode <= 39)) {
                    // let it happen, don't do anything
                    return;
                }
                else {
                    // Ensure that it is a number and stop the keypress
                    if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
                        event.preventDefault();
                    }
                }
            });
        });

        function validateForm() {
            var myBoolean = new Boolean();
            myBoolean = true;

            if (document.getElementById("booking_Guest_Email").value.length > 1) {
                var x = document.getElementById("booking_Guest_Email").value;
                var atpos = x.indexOf("@");
                var dotpos = x.lastIndexOf(".");
                if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= x.length) {
                    alert("Not a valid e-mail address");
                    return false;

                }

            }
            return myBoolean;
        } 
    </script>
    <%
        using (Ajax.BeginForm("EditUserInfo", new AjaxOptions { UpdateTargetId = "user_result", OnBegin = "validateForm" }))
    { %>
	<tr>
		<td style="width: 163px">Booking Number </td>
		<td style="font-size:x-large;color:Red" colspan="3"> <% =Model.booking.BookingNumber%></td>
         <%= Html.HiddenFor(model => model.booking.ID)%>
	</tr>
	<tr>
		<td colspan="1" style="width: 163px">Arrival Date</td>
		<td colspan="3"><% =Model.booking.StartDate%></td>
	</tr>
    <tr>
		<td colspan="1" style="width: 163px">Depature Date</td>
		<td colspan="3"><% =Model.booking.EndDate%></td>
	</tr> 
    <tr>
        <td colspan="1" style="width: 163px">Booking Status</td>
		<td colspan="3"><% =Model.booking.BookingStatus%>
        <% if (Session["isBookingCancelable"] != null)
           {
               if (Session["isBookingCancelable"].ToString().Equals("True"))
               {
                   %>
                    <%: Html.ActionLink("Cancel", "Cancel", new { id = Model.booking.ID })%>
                   <%
    }
           }
             %>
        </td>
	</tr>

    <tr>
		<td bgcolor="#C0C0C0" colspan="4" style="height: 23px">Booking User Information</td>
	</tr>
    
	<tr>
		<td colspan="1" style="width: 163px">Name</td>
		<td colspan="3"><% =Model.booking.Guest.FirstName%>&nbsp;<% =Model.booking.Guest.LastName%></td>
	</tr>
	<tr>
		<td colspan="1" style="width: 163px">  <%= Html.LabelFor(model => model.booking.Guest.Phone)%></td>
		<td colspan="3">  <%= Html.EditorFor(model => model.booking.Guest.Phone)%>  </td>
	</tr>
	<tr>
		<td colspan="1" style="width: 163px">Email</td>
		<td colspan="3"> <%= Html.EditorFor(model => model.booking.Guest.Email)%> </td>
	</tr>
	<tr>
		<td colspan="1" style="width: 163px">Address</td>
		<td colspan="3"> <%= Html.EditorFor(model => model.booking.Guest.Address)%> </td>
	</tr>
	<tr>
		<td colspan="1" style="width: 163px">City</td>
		<td colspan="3"> <%= Html.EditorFor(model => model.booking.Guest.City)%> </td>
	</tr>
    <tr>
		<td colspan="1" style="width: 163px">State</td>
		<td colspan="3"> <%= Html.EditorFor(model => model.booking.Guest.State)%> </td>
	</tr>
    <tr>
		<td colspan="1" style="width: 163px">Postal Code</td>
		<td colspan="3"> <%= Html.EditorFor(model => model.booking.Guest.ZipPostalCode)%><%= Html.ValidationMessageFor(model => model.booking.Guest.ZipPostalCode)%> </td>
	</tr>
     <tr>
		<td colspan="1" style="width: 163px"> 
        <% if (Session["isBookingUpdateable"] != null)
           {
               if (Session["isBookingUpdateable"].ToString().Equals("True"))
               {
                   %>
                    <input type="submit" value="Save" />
                   <%
    }
           }
             %></td>
		<td colspan="3">   <span id="user_result"></span> </td>
	</tr>
	<% } %>


    <tr>
		<td bgcolor="#C0C0C0" colspan="4" style="height: 23px">Room Details</td>
	</tr>
     <% foreach (var room in Model.booking.BookingDetails)
        { %>
    <tr>
		<td>Room Type  </td>
		<td><% =room.RoomType.RoomTypeName%></td>
		<td  colspan="2">Number of room <% =room.RoomCount%> </td>
	</tr>
	 <% } %>
     <tr>
		<td bgcolor="#C0C0C0" colspan="4" style="height: 23px">Roomm Facilities</td>
	</tr>
  	<tr>
		<td colspan="4">  <% foreach (var facitliy in Model.booking.BookingFacilities)
                       { %> <% =facitliy.Facility.Name%>  <% } %> </td>
	</tr>
	

    <tr>
		<td bgcolor="#C0C0C0" colspan="4" style="height: 23px">Guest Details</td>
	</tr>
 
     <% if (Model.guests != null && Model.guests.Count() > 0)
        {
            //using (Html.BeginForm("EditGuest", "Booking/EditGuest", FormMethod.Post, new { enctype = "multipart/form-data" }))
            using (Ajax.BeginForm("EditGuest", new AjaxOptions { UpdateTargetId = "result" }))
            {
                Html.RenderPartial("ViewGuest", Model);
            }
        }
         %>

        

</table>
<%}
  else
  {
 %> 
 Sorry, We cannot find the booking.
<%
}
 %> 
</asp:Content>
